#include <iostream>
#include <vector>
#include "../utils.h"

bool findNum(const std::vector<std::vector<int>> &input, const int &num) {
  auto row = input.size();
  auto col = input[0].size();
  auto i = 0;
  auto j = col - 1;
  while ((i < row) && (j >= 0)) {
    if (input[i][j] == num) {
      return true;
    } else if (input[i][j] > num) {
      --j;
    } else {
      ++i;
    }
  }
  return false;
}

int main() {
  std::vector<std::vector<int>> input = {{1, 2, 8, 9}, {2, 4, 9, 12}, {4, 7, 10, 13}, {6, 8, 11, 15}};
  printVec("o4", input);
  bool ret = findNum(input, 7);
  std::cout << "find number or not: " << ret << std::endl;
  return 0;
}
